//
// Created by heqian on 17-8-16.
//

#ifndef AUTOMAHJONG_HTTPCLIENT_H
#define AUTOMAHJONG_HTTPCLIENT_H

#include <string>
#include <map>

#include "Prt.h"
#include "Socket.h"

using namespace std;

namespace utils {

    class HttpClient {
    public:
        HttpClient();


        const string &getUrl() const;

        void get(const string &mUrl);

        void post(const string &mUrl);

        const string &getData() const;

        void setData(const char *data, int len);

        const string &getBodyData() const;


    protected:
        string mUrl;
        string mData;

        string mHost;
        int mPort;
        string mMethod;
        string mURLPart;
        map<string, string> mHead;

        void re(bool isPost);

        void parseHost(string &basic);

        string mBodyData;

        void addHead(string &key, string &value);
    };

}
#endif //AUTOMAHJONG_HTTPCLIENT_H
